package com.notes.java.generic;

import com.notes.domain.User;

import java.util.ArrayList;
import java.util.List;

/**
 * @author
 * @Describe 功能描述
 * @date
 */
public class GenericDemo {
    public <T> T test(User user) {
        return (T) user;
    }

    public static <T> String a(T t) {
        return (String) t;
    }

    public static <T> T b(T t) {
        return t;
    }

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, InstantiationException {
        Integer b = b(123);
        System.out.println(b);

        List<String> list1 = new ArrayList<String>();
        List<Integer> list2 = new ArrayList<Integer>();
        fun2(list1);
        fun2(list2);

        List<? extends Number> list = new ArrayList<>();
        Number number = list.get(0);
        //list.add(1);

        List<? super Number> list3 = new ArrayList<>();
        // Number number2 = list2.get(0);
        list2.add(1);

        String.valueOf(1);

        List<?> list4 = new ArrayList<String>();

    }

    public static void fun(List<Object> list) {
        System.out.println(list);
    }

    public static <T> void fun2(List<?> list) {
        System.out.println(list);
    }
}
